<%-- 
    Document   : kq
    Created on : May 27, 2012, 2:00:08 PM
    Author     : 0912153
--%>

<%@page import="java.util.Calendar"%>
<%@page import="java.util.Date"%>
<%@page import="testonlineconnectdb.UserInfo"%>
<%@page import="testonlineconnectdb.Question"%>
<%@page import="testonlineconnectdb.TestType"%>
<%@page import="java.util.ArrayList"%>
<%@page import="testonlineconnectdb.TestOnlineConnectDB"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Kết quả bài thi</title>
    </head>
    <body>
<%
        request.setCharacterEncoding("UTF-8");
        int timeo = 0;
        String realPath = config.getServletContext().getRealPath("") + "\\OnlineDatabase\\";
        TestOnlineConnectDB cDB = new TestOnlineConnectDB();        
        cDB.Connect(realPath + "OnlineDB.accdb");
        ArrayList ExamQuestionsByCode = cDB.GetExamQuestionsByCode(Integer.parseInt(request.getParameter("made")),realPath + "BankQuestion.xml" );
        int dung = 0;
        for(int i =0; i < ExamQuestionsByCode.size()-1; i++)
        {
            Question temp = (Question)ExamQuestionsByCode.get(i);
            if(request.getParameter(temp.code) != null)
            {
                if(request.getParameter(temp.code).equals(temp.result))
                    ++dung;
            }
        }
%>
Số câu đúng: <% out.println(dung); %>
<br/>
Số điểm: 
<%
    float diem = (float)dung / (float)(ExamQuestionsByCode.size()-1) * 10;
    out.println(diem + "<br/>Kết quả: ");
    if(diem >= 5 )
        out.println("Đạt");
    else
        out.println("Rớt");
    
    UserInfo usrI = new UserInfo();
    usrI.name = request.getParameter("hoten");
    usrI.identity = request.getParameter("cmnd");
    usrI.testCode = Integer.parseInt(request.getParameter("made"));
    
    java.sql.Date datebd = new java.sql.Date(1,1,1);
    long templong = Long.parseLong(request.getParameter("ngaybd"));
    datebd.setTime(templong);
    usrI.dayStart = datebd;
    
    Calendar cal = Calendar.getInstance();
    java.sql.Date datekt = new java.sql.Date(cal.getTime().getTime());
    usrI.dayEnd = datekt;
    
    usrI.score = (int)diem;
    usrI.answers = "123";
    
    cDB.UpdateUser(usrI);
    
%>
        
        
        
        
        
        
    </body>
</html>
